package org.example.controller.authorization.resource;

import com.bianmaba.spring.web.controller.CrudController;
import com.bianmaba.commons.bean.result.OperationResult;
import com.bianmaba.spring.mvc.annotation.RequestResponseBodyConfig;
import com.bianmaba.spring.mvc.config.annotation.EntityParam;
import org.example.bean.entity.authorization.Resource;
import org.example.service.authorization.resource.IResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by cwx183898 on 2017/8/10.
 */
@RestController
@RequestMapping(value = {"management/authorization/resource"})
public class MGTResourceController extends CrudController<Resource, String> {

    @Autowired
    private IResourceService service;

    @Override
    protected IResourceService getService() {
        return service;
    }

    @Override
    @RequestResponseBodyConfig(excludeProperties = "data.*\\.users\\.resources,data.*\\.roles\\.resources")
    public OperationResult<Resource> saveFromFormdata(@EntityParam Resource entity) {
        return super.saveFromFormdata(entity);
    }

    @Override
    @RequestResponseBodyConfig(excludeProperties = "data.*\\.roles\\.resources,data.*\\.roles\\.users")
    public OperationResult<Resource> getById(String id) {
        return super.getById(id);
    }

//    @JSON(excludeProperties = "data.*\\.roles")
//    public QueryResult<List<Resource>> query(@RequestBody PageableCondition condition) {
//        QueryResult<List<Resource>> page = super.query(condition);
//        return page;
//    }

}
